package com.qiudaozhang.loveblog.service.impl;

import com.qiudaozhang.loveblog.entity.Category;
import com.qiudaozhang.loveblog.repository.CategoryRepository;
import com.qiudaozhang.loveblog.service.CategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author 邱道长
 * 2019/11/13
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Resource
    private CategoryRepository cr;

    @Override
    public List<Category> findAll() {
        Iterable<Category> all = cr.findAll();
        List<Category> categories  = new ArrayList<>();
        Iterator<Category> it = all.iterator();
        while(it.hasNext()){
            categories.add(it.next());
        }
        return categories;
    }
}
